from django.shortcuts import render
from .models import *
from .serializers import *
# Create your views here.
from  rest_framework.viewsets import ModelViewSet
from rest_framework.views import APIView
from rest_framework.generics import ListAPIView
from rest_framework.pagination import PageNumberPagination
class MyPagenation(PageNumberPagination):
    page_size = 3
    max_page_size = 5
    page_query_param = "page"
    page_size_query_param = "pagesize"
class CouponViewSet(ModelViewSet):
    queryset = Coupon.objects.all()
    serializer_class = CouponSer
    lookup_field = 'pk'
    lookup_url_kwarg = 'pk'
    pagination_class = MyPagenation

#加载所有的优惠券类型
class CouponTypeAPIView(ListAPIView):
    queryset = CouponType.objects.all()
    serializer_class = CouponTypeSer